#include "MotorDev.h"
#include "Global.h"
#include "timer.h"
#include "LED.h"
#include "UART.h"   


bit F_STATE_VALVE;
uint8 F_VALVE_DIR;


void MotorDev_HardwareConfig(void)
{
    //IO控制型
    _pms   = 0b00001111;  
    _ssctl = 0B00000001;
    _pxc   = 0B00000000; 
    _hvc   = 0B00000000;
}

void OpenValve(void)
{
    if(F_STATE_VALVE == 0)
    {
        F_STATE_VALVE = 1;
        
        if(F_VALVE_DIR == 0)    MOTOR_FORWARD();
        else                    MOTOR_BACKWARD();
        DelayXmSec(40 * T1MS);
        MOTOR_STOP();
#ifdef _UART_EN_
        // UART_Printf("Open\r\n");
        UART_SendByte(0xF1);
#endif
    }
}

void CloseValve(void)
{
    if(F_STATE_VALVE)
    {
        F_STATE_VALVE = 0;

        if(F_VALVE_DIR == 0)    MOTOR_BACKWARD();
        else                    MOTOR_FORWARD();
        DelayXmSec(40 * T1MS);
        MOTOR_STOP();
#ifdef _UART_EN_           
        // UART_Printf("Close\r\n");
        UART_SendByte(0xF0);
#endif
    }
}

